Skip to content

feat(ui): suggest nearest slash commands on unknown input#302

Merged
esengine merged 1 commit intoesengine:mainfrom
zerone0x:feat/slash-nearest-command-17
May 9, 2026
Merged

feat(ui): suggest nearest slash commands on unknown input#302
esengine merged 1 commit intoesengine:mainfrom
zerone0x:feat/slash-nearest-command-17

Conversation

@zerone0x
Copy link
Copy Markdown
Contributor

@zerone0x zerone0x commented May 6, 2026

What

Unknown slash-command errors now suggest up to three nearby registered commands instead of always falling back to /help. Added a small Levenshtein helper and regression coverage for typo, omission, insertion, transposition, and no-match cases.

Why

Closes #17. A typo like /upadte was a wasted turn even though the command set is already known at dispatch time. Suggesting the nearest commands turns that into a one-step correction.

How to verify

  • npx biome check src/cli/ui/slash/dispatch.ts src/cli/ui/slash/nearest.ts tests/slash-nearest.test.ts
  • npm test -- --silent tests/slash-nearest.test.ts tests/slash.test.ts
  • In the TUI, type /upadte and confirm the error says did you mean /update?

Checklist

  • npm run verify passes locally (lint + typecheck + tests + comment-policy gate)
  • No Co-Authored-By: Claude trailer in commits
  • Comments follow CONTRIBUTING.md (no module-essay headers, no incident history)
  • No edits to CHANGELOG.md — release notes are maintainer-written at release time

@esengine
Copy link
Copy Markdown
Owner

esengine commented May 6, 2026

Thanks for picking this up — the implementation matches the spec cleanly. Wagner-Fischer DP, the half-length cap for very short inputs, the alphabetical tiebreak for deterministic output, and all five test cases (typo / missing / extra / transposition / no-match) are covered. Nice work for a first PR.

One blocker on CI: typecheck fails because the repo runs noUncheckedIndexedAccess: true, so the indexed reads in the inner DP loop come back as number | undefined. Three ! assertions on line 33 will clear it:

next[j + 1] = Math.min(next[j]! + 1, prev[j + 1]! + 1, prev[j]! + cost);

The trailing prev[b.length] ?? 0 is already fine — that one doesn't need a change.

Push that and I'll merge.

@dacec354
Copy link
Copy Markdown
Contributor

dacec354 commented May 8, 2026

any progress? want this feature

@esengine esengine force-pushed the feat/slash-nearest-command-17 branch from dada847 to 34454a8 Compare May 9, 2026 13:07
@esengine esengine merged commit 7f54ae0 into esengine:main May 9, 2026
2 checks passed
@esengine
Copy link
Copy Markdown
Owner

esengine commented May 9, 2026

Merged — thanks @zerone0x! Took the liberty of rebasing onto current main, fixing the 3 noUncheckedIndexedAccess type errors in the levenshtein loop, and resolving the dispatch.ts import conflict; pushed the result to your branch and squash-merged. Levenshtein helper is clean, test coverage is solid. Apologies for the slow review — appreciate your patience.

@esengine esengine mentioned this pull request May 9, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggest the closest slash command on unknown command errors

3 participants